﻿using Abp.Runtime.Validation;
using Mt.Site.Application.Dto;
using Mt.Site.Core.WorkFlows.Enum;
using System;
using System.Collections.Generic;

namespace Mt.Site.Application.WorkFlows.Dto.wf
{
    public class PaperInputFieldName
    {
        public const string ShenHe = "当前审核状态";//xx审核 or 已通过 or --(拟稿)
    }

    public class PagedPaperInput : PagedSortedAndFilteredInputDto, IShouldNormalize , IPagedPaperInputPara
    {
        public List<string> FieldList { get; set; }
        
        public PaperState PaperState { get; set; }


        public RunTimeState ActionState { get; set; }
        public OperationType? OperationType { get; set; }

        public DateTime? StartDate { get; set; }
        public DateTime? EndDate { get; set; } 

        public List<Guid> InclusiveWorkFlowId { get; set; }
        public List<Guid> ExclusiveWorkFlowId { get; set; }

        public WorkFlowQueryType WfQueryType { get; set; }

        public string WorkFlowUniqueName { get; set; }

        public long UserId { get; set; }

        public long UnitId { get; set; }

        public ApprovalResult? ApprovalResult { get; set; }

        public Guid? NodeId { get; set; }

        public void Normalize()
        {
            ResolveParameters();
        }

        protected virtual void ResolveParameters()
        {
            switch (WfQueryType)
            {
                case WorkFlowQueryType.Draft:
                    ActionState = RunTimeState.Todo;
                    PaperState = PaperState.Draft;
                    break;

                case WorkFlowQueryType.Todo:
                    ActionState = RunTimeState.Todo;
                    PaperState = PaperState.Running;
                    //OperationType = Core.WorkFlows.Enum.OperationType.Processing;
                    break;

                case WorkFlowQueryType.Related:
                    ActionState = RunTimeState.Related;
                    PaperState = PaperState.Running;
                    //OperationType = Core.WorkFlows.Enum.OperationType.Processing;
                    break;

                //case WorkFlowQueryType.ToRead:
                //    ActionState = ActionState.Todo;
                //    PaperState = PaperState.Running;
                //    OperationType = Core.WorkFlows.Enum.OperationType.PassRound;
                //    break;

                //case WorkFlowQueryType.HasRead:
                //    ActionState = ActionState.Related;
                //    PaperState = PaperState.Running;
                //    OperationType = Core.WorkFlows.Enum.OperationType.PassRound;
                //    break;

                case WorkFlowQueryType.Finished:
                    ActionState = RunTimeState.Related;
                    PaperState = PaperState.Finished;
                    //OperationType = Core.WorkFlows.Enum.OperationType.Processing;
                    break;
            }
        }
    }
}
